﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>确认支付</title>  
    <link href="~/Content/css/jquery-weui.css" rel="stylesheet" />
    <link href="~/Content/css/weui.min.css" rel="stylesheet" />
    <link href="~/Content/css/demos.css" rel="stylesheet" />
  
    <script src="~/Scripts/jquery-1.6.4.js"></script>
</head>
<body ontouchstart>
    <header class='demos-header'>
        <h1 class="demos-title" style="color:black">￥@ViewBag.fee</h1>
    </header>
    <div class='demos-content-padded'>
        @*<button onclick="callpay()">确认支付</button>*@
        <a href="javascript:callpay();" class="weui-btn weui-btn_primary">确认支付</a>
    </div>
    <input type="hidden" id="out_trade_no" value="@ViewBag.out_trade_no" />
   
    <input type="hidden" id="hyid" value="@ViewBag.hyid" />
    <input type="hidden" id="brid" value="@ViewBag.brid" />
  
    <script>

        var int=self.setInterval("queryOrder()",1000);

        function queryOrder(){
          
            $.post("queryOrder",{"out_trade_no":$("#out_trade_no").val(),"hyid":$("#hyid").val(),"brid":$("#brid").val()},function(data){
                    if(data=="0"){
                        //alert("支付成功");
                        window.location.href = "/PayFee/PaySuccess";
                    }else if(data=="1"){
                        window.location.href = "/PayFee/PayFail";
                    }

                })
          
        }

        //调用微信JS api 支付
        function jsApiCall()
        {
            WeixinJSBridge.invoke(
            'getBrandWCPayRequest',
            @Html.Raw(ViewBag.wxJsApiParam) ,//josn串
             function (res)
             {
                 WeixinJSBridge.log(res.err_msg);
                 //alert(res.err_code + res.err_desc + res.err_msg);
             }
             );
        }

        function callpay()
        {
        
            if (typeof WeixinJSBridge == "undefined")
            {
                if (document.addEventListener)
                {
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                }
                else if (document.attachEvent)
                {
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            }
            else
            {
                jsApiCall();
            }
        }

    </script>
</body>
</html>
